package com.bingxue.edu.management.auth.model.resp;

import com.bingxue.edu.management.system.model.resp.EmployeeResp;
import com.bingxue.edu.management.system.model.resp.RoleNameResp;
import com.mybatisflex.annotation.RelationManyToMany;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 员工详情信息
 *
 * @author panbo
 * @since 2024/07/10 16:12
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "员工详情信息")
public class EmployeeUserDetailResp extends EmployeeResp {
    @RelationManyToMany(
            joinTable = "base_role_employee",
            selfField = "id", joinSelfColumn = "employee_id",
            targetField = "id", joinTargetColumn = "role_id", targetTable = "base_role"
    )
    @Schema(description = "角色列表")
    private List<RoleNameResp> roleList;

    @Schema(description = "角色id列表")
    public List<String> getRoleIdList() {
        return roleList.stream().map(RoleNameResp::getId).toList();
    }
}
